﻿
namespace Common.DB
{
    /// <summary>
    /// 分页查询参数对象
    /// </summary>
    public class Paging
    {
        public Paging()
        {

        }
        public Paging(int _CurrentPageIndex, int _PageSize = 20, string _SortFields = "Id", SortType _SortType = SortType.ASC)
        {
            this.CurrentPageIndex = _CurrentPageIndex;
            this.PageSize = _PageSize;
            this.SortFields = _SortFields;
            this.SortType = _SortType;
        }
        /// <summary>
        /// 当前页数
        /// </summary>
        public int CurrentPageIndex = 1;
        /// <summary>
        /// 每页行数
        /// </summary>
        public int PageSize = 20;
        /// <summary>
        /// 排序字段名称
        /// </summary>
        public string SortFields = "";
        /// <summary>
        /// 排序类型
        /// </summary>
        public SortType SortType;
        /// <summary>
        /// 查询语句
        /// </summary>
        public string SQL = "";
        /// <summary>
        /// 总行数
        /// </summary>
        public int TotalCount;
        /// <summary>
        /// 总页数
        /// </summary>
        public int PageConut
        {
            get
            {
                int pageCount = this.TotalCount / this.PageSize;
                if (this.TotalCount % this.PageSize > 0)
                {
                    pageCount++;
                }
                return pageCount;
            }
        }
    }
    public enum SortType
    {
        DESC,
        ASC
    }
}
